package cn.lhz.controller;

import cn.lhz.dto.ItalyMonth;
import cn.lhz.service.ItalyMonthService;
import cn.lhz.util.response.ResponseController;
import cn.lhz.util.response.ResponseResult;
import cn.lhz.util.list.ListToChart;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 年阔正
 * @version 1.0.0
 */
@RestController
@RequestMapping("/ItalyMonth")
@RequiredArgsConstructor
public class ItalyMonthController {

  private final ItalyMonthService ItalyMonthService;

  // 提供接口
  @GetMapping("/list")
  public ResponseResult<List<ItalyMonth>> getItalyMonthData() {
    List<ItalyMonth> data = ItalyMonthService.getItalyMonthData();
    if (data.isEmpty()) {
      return ResponseController.dataEmpty();  // 返回未查询到数据的响应
    }
    return ResponseController.success(data);  // 返回查询到的数据
  }



  @GetMapping("/pileUp")
  public List<List<Object>> pileUp() throws IllegalAccessException {
    List<ItalyMonth> data = ItalyMonthService.getItalyMonthData();
    return ListToChart.pileUp(ResponseController.success(data).getData(), ItalyMonth.class);
  }


}
